package com.sensePlusVR.activity.mine;

import java.util.ArrayList;
import java.util.List;

import org.xutils.x;
import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.sensePlusVR.adapter.StoreAdapter;
import com.sensePlusVR.adapter.StoreAdapter.OnRecyclerViewItemClickListener;
import com.sensePlusVR.base.BaseActivity;
import com.sensePlusVR.bean.StoreItem;
import com.sensePlusVR.main.R;
import com.sensePlusVR.utils.AppManager;
import com.sensePlusVR.utils.MyToast;
/**
 * 
 * @author: Loren
 * @create: 2016-8-10下午2:46:28
 * @desc: My --> Setting --> Feedback -->Store
 *
 */
@SuppressWarnings("unused")
@ContentView(R.layout.activity_setting_core_stroe)
public class StoreActivity extends BaseActivity implements OnRecyclerViewItemClickListener{
	private static final String TAG = StoreActivity.class.getSimpleName();
	@ViewInject(R.id.title_bar_title_tv)
	private TextView title_bar_title_tv;
	private List<StoreItem> storeList;
	private StoreAdapter adapter;
	@ViewInject(R.id.feedback_store_listview)
	private RecyclerView feedback_store_listview;
	
	@Override
	public void setMyContentView() {
		x.view().inject(this);
	}
	
	@Override
	public void beforeView() {
		super.beforeView();
		getData();
		adapter = new StoreAdapter(storeList);
		adapter.setOnRecyclerViewItemClickListener(this);
	}
	
	private void getData() {
		storeList = new ArrayList<StoreItem>();
		for (int i = 0; i < 20; i++) {
			StoreItem item = new StoreItem();
			//XXX 没有赞数和评论数先用rating和price字段代替
			item.setTitle("New Adult supplies store" + i);
			item.setDesc("New York three street No. 45 201");
			item.setDistance("100m");
			storeList.add(item);
		}
	}
	
	@Override
	public void initView() {
		super.initView();
		AppManager.getInstance().addActivity(this);
		title_bar_title_tv.setText(R.string.store);
		
		LinearLayoutManager layoutManager = new LinearLayoutManager(this);
		feedback_store_listview.setLayoutManager(layoutManager);
		feedback_store_listview.setAdapter(adapter);
	}
	
	@Event(value = {R.id.title_bar_left_ib})
	private void setViewOnClick(View view){
		switch (view.getId()) {
		case R.id.title_bar_left_ib:
			AppManager.getInstance().finishActivity(this);
			break;

		default:
			break;
		}
	}

	@Override
	public void OnItemClick(View view, StoreItem item) {
		MyToast.showMessage(this, "store title : " + item.getTitle());
	}

}
